/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PresentationTier;

import BusinessTier.EmpresaBUS;
import BusinessTier.IBGEBUS;
import EntitiesTier.ClEmpresa;
import EntitiesTier.ClIBGE;
import PresentationTier.Pesquisa.GUIEmpresaPesquisar;
import PresentationTier.Pesquisa.GUIIBGEPesquisar;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Douglas
 */
public class GUICadEmpresa extends javax.swing.JInternalFrame {
    
    public ClEmpresa cl;
    public ClIBGE clIBGE;
    private String state;

    /**
     * Creates new form GUICadEmpresa
     */
    public GUICadEmpresa() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        edtCPF = new javax.swing.JTextField();
        lblApl = new javax.swing.JLabel();
        lblRazao = new javax.swing.JLabel();
        edtApelido = new javax.swing.JTextField();
        edtNome = new javax.swing.JTextField();
        edtRG = new javax.swing.JTextField();
        lblRG = new javax.swing.JLabel();
        lblCPF = new javax.swing.JLabel();
        lblCodCont = new javax.swing.JLabel();
        pnEnd = new javax.swing.JPanel();
        lvlEnd = new javax.swing.JLabel();
        lblNum = new javax.swing.JLabel();
        edtEnd = new javax.swing.JTextField();
        edtNum = new javax.swing.JTextField();
        lblBairro = new javax.swing.JLabel();
        edtBairro = new javax.swing.JTextField();
        lblCompl = new javax.swing.JLabel();
        edtCompl = new javax.swing.JTextField();
        lvlCidade = new javax.swing.JLabel();
        edtCidade = new javax.swing.JTextField();
        lblUF = new javax.swing.JLabel();
        edtUF = new javax.swing.JTextField();
        lblCep = new javax.swing.JLabel();
        edtCep = new javax.swing.JTextField();
        btnIBGE = new javax.swing.JButton();
        edtIBGE = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        pnContato = new javax.swing.JPanel();
        edtSlogan = new javax.swing.JTextField();
        edtWeb = new javax.swing.JTextField();
        lblWeb = new javax.swing.JLabel();
        lblSlogan = new javax.swing.JLabel();
        lblFon1 = new javax.swing.JLabel();
        lblFon2 = new javax.swing.JLabel();
        lblFax = new javax.swing.JLabel();
        edtFone1 = new javax.swing.JTextField();
        edtFone2 = new javax.swing.JTextField();
        edtFax = new javax.swing.JTextField();
        edtEmail = new javax.swing.JTextField();
        lblEmail = new javax.swing.JLabel();
        edtSenha = new javax.swing.JTextField();
        lblEmail1 = new javax.swing.JLabel();
        lblSMTP = new javax.swing.JLabel();
        edtSMTP = new javax.swing.JTextField();
        lblPorta = new javax.swing.JLabel();
        edtPorta = new javax.swing.JTextField();
        lblInfAdic = new javax.swing.JLabel();
        edtInfAdic = new javax.swing.JTextField();
        pnNav = new javax.swing.JPanel();
        btnNovo = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        btnExcluir = new javax.swing.JButton();
        btnGravar = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();
        btnPesq = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        edtCPF.setEditable(false);

        lblApl.setText("Fantasia .:");

        lblRazao.setText("Razão .:");

        edtApelido.setEditable(false);
        edtApelido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edtApelidoActionPerformed(evt);
            }
        });

        edtNome.setEditable(false);

        edtRG.setEditable(false);

        lblRG.setText("IE .:");

        lblCPF.setText("CNPJ .:");

        lblCodCont.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblCodCont.setText("Código");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblCodCont, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(lblCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(lblApl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblRazao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(edtCPF)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lblRG, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtRG, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(edtApelido, javax.swing.GroupLayout.PREFERRED_SIZE, 434, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(edtNome, javax.swing.GroupLayout.PREFERRED_SIZE, 434, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblCodCont, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(edtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRazao))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(edtApelido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblApl))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblCPF)
                    .addComponent(edtCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblRG)
                    .addComponent(edtRG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnEnd.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lvlEnd.setText("Endereço .:");

        lblNum.setText("nº .:");

        edtEnd.setEditable(false);

        edtNum.setEditable(false);

        lblBairro.setText("Bairro .:");

        edtBairro.setEditable(false);

        lblCompl.setText("Complemento .:");

        edtCompl.setEditable(false);

        lvlCidade.setText("Cidade .:");

        edtCidade.setEditable(false);

        lblUF.setText("UF .:");

        edtUF.setEditable(false);

        lblCep.setText("CEP .:");

        edtCep.setEditable(false);

        btnIBGE.setText("Sel. IBGE");
        btnIBGE.setEnabled(false);
        btnIBGE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIBGEActionPerformed(evt);
            }
        });

        jLabel1.setText("IBGE .:");

        javax.swing.GroupLayout pnEndLayout = new javax.swing.GroupLayout(pnEnd);
        pnEnd.setLayout(pnEndLayout);
        pnEndLayout.setHorizontalGroup(
            pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnEndLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnEndLayout.createSequentialGroup()
                        .addComponent(lvlCidade)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtCidade)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblCep)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtCep, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtIBGE, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnIBGE))
                    .addGroup(pnEndLayout.createSequentialGroup()
                        .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnEndLayout.createSequentialGroup()
                                .addComponent(lvlEnd)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblNum))
                            .addGroup(pnEndLayout.createSequentialGroup()
                                .addComponent(lblCompl)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtCompl, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblBairro)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(edtNum, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnEndLayout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addComponent(lblUF)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(edtUF, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnEndLayout.setVerticalGroup(
            pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnEndLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lvlEnd)
                    .addComponent(edtEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNum)
                    .addComponent(edtNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblUF)
                        .addComponent(edtUF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblBairro)
                        .addComponent(edtBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lblCompl)
                        .addComponent(edtCompl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnEndLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lvlCidade)
                    .addComponent(edtCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCep)
                    .addComponent(edtCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnIBGE)
                    .addComponent(edtIBGE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(13, Short.MAX_VALUE))
        );

        pnContato.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        edtSlogan.setEditable(false);

        edtWeb.setEditable(false);

        lblWeb.setText("Web .:");

        lblSlogan.setText("Slogan .:");

        lblFon1.setText("Fone 1.:");

        lblFon2.setText("Fone 2 .:");

        lblFax.setText("Fax .:");

        edtFone1.setEditable(false);

        edtFone2.setEditable(false);

        edtFax.setEditable(false);

        edtEmail.setEditable(false);

        lblEmail.setText("Email .:");

        edtSenha.setEditable(false);

        lblEmail1.setText("Senha .:");

        lblSMTP.setText("SMTP .:");

        edtSMTP.setEditable(false);

        lblPorta.setText("Porta .:");

        edtPorta.setEditable(false);

        lblInfAdic.setText("Inf. Adic. .:");

        edtInfAdic.setEditable(false);

        javax.swing.GroupLayout pnContatoLayout = new javax.swing.GroupLayout(pnContato);
        pnContato.setLayout(pnContatoLayout);
        pnContatoLayout.setHorizontalGroup(
            pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnContatoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnContatoLayout.createSequentialGroup()
                        .addComponent(lblEmail1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(edtSenha, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblSMTP)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(edtSMTP, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblPorta)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(edtPorta))
                    .addGroup(pnContatoLayout.createSequentialGroup()
                        .addComponent(lblSlogan)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(edtSlogan, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblWeb))
                    .addGroup(pnContatoLayout.createSequentialGroup()
                        .addComponent(lblEmail)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(edtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(edtWeb, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(pnContatoLayout.createSequentialGroup()
                                .addComponent(lblFon1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtFone1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblFon2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtFone2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblFax)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edtFax, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnContatoLayout.createSequentialGroup()
                                .addComponent(lblInfAdic)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(edtInfAdic)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnContatoLayout.setVerticalGroup(
            pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnContatoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblFon1)
                    .addComponent(lblFon2)
                    .addComponent(lblFax)
                    .addComponent(edtFone1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(edtFone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(edtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSlogan)
                    .addComponent(edtSlogan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblWeb)
                    .addComponent(edtWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEmail)
                    .addComponent(edtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEmail1)
                    .addComponent(edtSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblSMTP)
                    .addComponent(edtSMTP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPorta)
                    .addComponent(edtPorta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnContatoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblInfAdic)
                    .addComponent(edtInfAdic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnNav.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnNav.setPreferredSize(new java.awt.Dimension(690, 65));

        btnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/add.png"))); // NOI18N
        btnNovo.setText("Novo");
        btnNovo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNovo.setMaximumSize(new java.awt.Dimension(50, 50));
        btnNovo.setMinimumSize(new java.awt.Dimension(50, 50));
        btnNovo.setPreferredSize(new java.awt.Dimension(50, 50));
        btnNovo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoActionPerformed(evt);
            }
        });

        btnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/cancel.png"))); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.setEnabled(false);
        btnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCancelar.setPreferredSize(new java.awt.Dimension(100, 40));
        btnCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        btnExcluir.setPreferredSize(new java.awt.Dimension(100, 40));
        btnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExcluirActionPerformed(evt);
            }
        });

        btnGravar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/Gravar.png"))); // NOI18N
        btnGravar.setText("Gravar");
        btnGravar.setEnabled(false);
        btnGravar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnGravar.setPreferredSize(new java.awt.Dimension(100, 40));
        btnGravar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnGravar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGravarActionPerformed(evt);
            }
        });

        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/Exit.png"))); // NOI18N
        btnSair.setText("Sair");
        btnSair.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSair.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });

        btnPesq.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/pesquisar.png"))); // NOI18N
        btnPesq.setText("Procurar");
        btnPesq.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPesq.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnPesq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPesqActionPerformed(evt);
            }
        });

        btnEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icones/edit.gif"))); // NOI18N
        btnEdit.setText("Editar");
        btnEdit.setEnabled(false);
        btnEdit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEdit.setMaximumSize(new java.awt.Dimension(73, 59));
        btnEdit.setMinimumSize(new java.awt.Dimension(73, 59));
        btnEdit.setPreferredSize(new java.awt.Dimension(73, 59));
        btnEdit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnNavLayout = new javax.swing.GroupLayout(pnNav);
        pnNav.setLayout(pnNavLayout);
        pnNavLayout.setHorizontalGroup(
            pnNavLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnNavLayout.createSequentialGroup()
                .addComponent(btnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnGravar, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPesq, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnSair, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );
        pnNavLayout.setVerticalGroup(
            pnNavLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnNavLayout.createSequentialGroup()
                .addComponent(btnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnNavLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnNavLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnSair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnGravar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnNovo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnPesq, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnNav, javax.swing.GroupLayout.DEFAULT_SIZE, 538, Short.MAX_VALUE)
            .addComponent(pnContato, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnEnd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnContato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnNav, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 36, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void edtApelidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_edtApelidoActionPerformed

    }//GEN-LAST:event_edtApelidoActionPerformed

    private void btnIBGEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIBGEActionPerformed
        Dimension tela =  Toolkit.getDefaultToolkit().getScreenSize();
        GUIIBGEPesquisar tPesqIBGE = new GUIIBGEPesquisar(null, true);
        tPesqIBGE.setLocation((tela.width- tPesqIBGE.getSize().width)/2,
            (tela.height- tPesqIBGE.getSize().height)/2);
        tPesqIBGE.setVisible(true);
        //Acrescentar essas linhas
        edtIBGE.setText(tPesqIBGE.IBGE);

        this.lblCodCont.setEnabled(true);
        this.lblCodCont.requestFocus();
        if (edtIBGE.getText() != "")
        {
            PreencheIBGE();
        }
        tPesqIBGE.setVisible(false);
    }//GEN-LAST:event_btnIBGEActionPerformed

    private void btnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoActionPerformed
        cl = new ClEmpresa();
        state = "INSERT";
        Ativa();
        LimpaCampos();
    }//GEN-LAST:event_btnNovoActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        if (lblCodCont.getText() == "Código")
        {
            cl = null;
            state = "";
            Desativa();
        }
        else
        {
            Desativa();
            state = "BROWSE";
            PreencheCampos();
        }
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExcluirActionPerformed
        if(cl.getEMP_COD() > 0)
        {
            if (JOptionPane.showConfirmDialog(null,"Deseja Excluir o cliente " + cl.getEMP_RAZAO() +" ?") == JOptionPane.YES_OPTION)
            {
                EmpresaBUS bus = new EmpresaBUS();
                try
                {
                    bus.excluir(cl.getEMP_COD());
                    LimpaCampos();
                } catch (Exception ex) {
                    Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }//GEN-LAST:event_btnExcluirActionPerformed

    private void btnGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGravarActionPerformed
        
        EmpresaBUS bus = new EmpresaBUS();
        carregadadoscl();
        if (cl.getEMP_COD() == 0)
        {
            try {
                cl.setEMP_COD(bus.inserir(cl));
            }
            catch (Exception ex)
            {
                Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
                state = "";
            }
            finally
            {
                btnEdit.setEnabled(true);
                state = "BROWSE";
                Desativa();
            }
        }
        else
        {
            try
            {
                bus.atualizar(cl);
            }
            catch (Exception ex)
            {
                Logger.getLogger(GUILancAdic.class.getName()).log(Level.SEVERE, null, ex);
                state = "BROWSE";
            }
            finally
            {
                btnEdit.setEnabled(true);
                state = "BROWSE";
                Desativa();
            }
        }
    }//GEN-LAST:event_btnGravarActionPerformed

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        try {
            this.setClosed(true);
        } catch (PropertyVetoException ex) {
            Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnSairActionPerformed

    private void btnPesqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPesqActionPerformed
        Dimension tela =  Toolkit.getDefaultToolkit().getScreenSize();
        GUIEmpresaPesquisar tPesqEmpresa = new GUIEmpresaPesquisar(null, true);
        tPesqEmpresa.setLocation((tela.width- tPesqEmpresa.getSize().width)/2,
            (tela.height- tPesqEmpresa.getSize().height)/2);
        tPesqEmpresa.setVisible(true);
        //Acrescentar essas linhas
        int idEmpresa =  tPesqEmpresa.codemp;

        this.lblCodCont.setEnabled(true);
        this.lblCodCont.requestFocus();
        if (idEmpresa > 0)
        {
            this.lblCodCont.setText(String.valueOf(idEmpresa));
            EmpresaBUS bus = new EmpresaBUS();
            try
            {
                cl = bus.buscar(idEmpresa);
                PreencheCampos();
            } catch (Exception ex) {
                Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
            }
            finally{
                state = "BROWSE";
            }
        }
        tPesqEmpresa.setVisible(false);
        btnEdit.setEnabled(true);

    }//GEN-LAST:event_btnPesqActionPerformed

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
        if( cl != null)
        state = "";
        Ativa();
    }//GEN-LAST:event_btnEditActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnEdit;
    private javax.swing.JButton btnExcluir;
    private javax.swing.JButton btnGravar;
    private javax.swing.JButton btnIBGE;
    private javax.swing.JButton btnNovo;
    private javax.swing.JButton btnPesq;
    private javax.swing.JButton btnSair;
    private javax.swing.JTextField edtApelido;
    private javax.swing.JTextField edtBairro;
    private javax.swing.JTextField edtCPF;
    private javax.swing.JTextField edtCep;
    private javax.swing.JTextField edtCidade;
    private javax.swing.JTextField edtCompl;
    private javax.swing.JTextField edtEmail;
    private javax.swing.JTextField edtEnd;
    private javax.swing.JTextField edtFax;
    private javax.swing.JTextField edtFone1;
    private javax.swing.JTextField edtFone2;
    private javax.swing.JTextField edtIBGE;
    private javax.swing.JTextField edtInfAdic;
    private javax.swing.JTextField edtNome;
    private javax.swing.JTextField edtNum;
    private javax.swing.JTextField edtPorta;
    private javax.swing.JTextField edtRG;
    private javax.swing.JTextField edtSMTP;
    private javax.swing.JTextField edtSenha;
    private javax.swing.JTextField edtSlogan;
    private javax.swing.JTextField edtUF;
    private javax.swing.JTextField edtWeb;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblApl;
    private javax.swing.JLabel lblBairro;
    private javax.swing.JLabel lblCPF;
    private javax.swing.JLabel lblCep;
    private javax.swing.JLabel lblCodCont;
    private javax.swing.JLabel lblCompl;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblEmail1;
    private javax.swing.JLabel lblFax;
    private javax.swing.JLabel lblFon1;
    private javax.swing.JLabel lblFon2;
    private javax.swing.JLabel lblInfAdic;
    private javax.swing.JLabel lblNum;
    private javax.swing.JLabel lblPorta;
    private javax.swing.JLabel lblRG;
    private javax.swing.JLabel lblRazao;
    private javax.swing.JLabel lblSMTP;
    private javax.swing.JLabel lblSlogan;
    private javax.swing.JLabel lblUF;
    private javax.swing.JLabel lblWeb;
    private javax.swing.JLabel lvlCidade;
    private javax.swing.JLabel lvlEnd;
    private javax.swing.JPanel pnContato;
    private javax.swing.JPanel pnEnd;
    private javax.swing.JPanel pnNav;
    // End of variables declaration//GEN-END:variables

    private void PreencheIBGE() {
            IBGEBUS bus = new IBGEBUS();
            try 
            {
                clIBGE = bus.buscar(edtIBGE.getText());
                edtCidade.setText(clIBGE.getIBGE_CIDADE());
                edtUF.setText(clIBGE.getIBGE_UF());
            } catch (Exception ex) {
                Logger.getLogger(GUICadContratado.class.getName()).log(Level.SEVERE, null, ex);
            }
    }

    private void Ativa() {
        edtNome.setEditable(true);
        edtApelido.setEditable(true);
        edtRG.setEditable(true);
        edtCPF.setEditable(true);
        edtEnd.setEditable(true);
        edtNum.setEditable(true);
        edtCompl.setEditable(true);
        edtWeb.setEditable(true);
        edtCidade.setEditable(true);
        edtUF.setEditable(true);
        edtCep.setEditable(true);
        edtFone1.setEditable(true);
        edtFone2.setEditable(true);
        edtFax.setEditable(true);
        edtEmail.setEditable(true);
        edtSlogan.setEditable(true);
        edtSenha.setEditable(true);
        edtBairro.setEditable(true);
        edtIBGE.setEditable(true);
        edtSMTP.setEditable(true);
        edtPorta.setEditable(true);
        edtInfAdic.setEditable(true);
        btnIBGE.setEnabled(true);

        btnCancelar.setEnabled(true);
        btnGravar.setEnabled(true);
        btnEdit.setEnabled(false);
        btnNovo.setEnabled(false);
        btnPesq.setEnabled(false);
    }

    private void LimpaCampos() {
        edtNome.setText("");
        edtApelido.setText("");
        edtRG.setText("");
        edtCPF.setText("");
        edtEnd.setText("");
        edtNum.setText("");
        edtCompl.setText("");
        edtCidade.setText("");
        edtUF.setText("");
        edtCep.setText("");
        edtFone1.setText("");
        edtFone2.setText("");
        edtFax.setText("");
        edtEmail.setText("");
        edtSlogan.setText("");
        edtSenha.setText("");
        edtBairro.setText("");
        edtIBGE.setText("");
        edtSMTP.setText("");
        edtPorta.setText("");
        edtInfAdic.setText("");
        edtWeb.setText("");
    }

    private void Desativa() {
        edtNome.setEditable(false);
        edtApelido.setEditable(false);
        edtRG.setEditable(false);
        edtCPF.setEditable(false);
        edtEnd.setEditable(false);
        edtNum.setEditable(false);
        edtCompl.setEditable(false);
        edtWeb.setEditable(false);
        edtCidade.setEditable(false);
        edtUF.setEditable(false);
        edtCep.setEditable(false);
        edtFone1.setEditable(false);
        edtFone2.setEditable(false);
        edtFax.setEditable(false);
        edtEmail.setEditable(false);
        edtSlogan.setEditable(false);
        edtSenha.setEditable(false);
        edtBairro.setEditable(false);
        edtIBGE.setEditable(false);
        edtSMTP.setEditable(false);
        edtPorta.setEditable(false);
        edtInfAdic.setEditable(false);
        btnIBGE.setEnabled(false);
        btnCancelar.setEnabled(false);
        btnGravar.setEnabled(false);
        if (state == "BROWSE")
            btnEdit.setEnabled(true);
        else
            btnEdit.setEnabled(false);
        btnNovo.setEnabled(true);
        btnPesq.setEnabled(true);
    }

    private void PreencheCampos() {
        lblCodCont.setText(String.valueOf(cl.getEMP_COD()));
        edtNome.setText(cl.getEMP_RAZAO());
        edtApelido.setText(cl.getEMP_NOME());
        edtRG.setText(cl.getEMP_IE());
        edtCPF.setText(cl.getEMP_CNPJ());
        edtEnd.setText(cl.getEMP_ENDERECO());
        edtNum.setText(cl.getEMP_NUM());
        edtCompl.setText(cl.getEMP_COMPLEMENTO());
        edtCidade.setText(cl.getEMP_CIDADE());
        edtUF.setText(cl.getEMP_UF());
        edtCep.setText(cl.getEMP_CEP());
        edtFone1.setText(cl.getEMP_FONE1());
        edtFone2.setText(cl.getEMP_FONE2());
        edtFax.setText(cl.getEMP_FAX());
        edtEmail.setText(cl.getEMP_EMAIL());
        edtSlogan.setText(cl.getEMP_SLOGAN());
        edtSenha.setText(cl.getEMP_SENHA());
        edtBairro.setText(cl.getEMP_BAIRRO());
        edtSMTP.setText(cl.getEMP_SMTP());
        edtPorta.setText(String.valueOf(cl.getEMP_PORTA() ));
        edtInfAdic.setText(cl.getEMP_INFOADIC());
        edtIBGE.setText(cl.getEMP_CDIBGE());
        PreencheIBGE();
    }

    private void carregadadoscl() {
        cl.setEMP_RAZAO(edtNome.getText());
        cl.setEMP_NOME(edtApelido.getText());
        cl.setEMP_IE(edtRG.getText());
        cl.setEMP_CNPJ(edtCPF.getText());
        cl.setEMP_ENDERECO(edtEnd.getText());
        cl.setEMP_NUM(edtNum.getText());
        cl.setEMP_COMPLEMENTO(edtCompl.getText());
        cl.setEMP_CIDADE(edtCidade.getText());
        cl.setEMP_UF(edtUF.getText());
        cl.setEMP_CEP(edtCep.getText());
        cl.setEMP_CDIBGE(edtIBGE.getText());
        cl.setEMP_FONE1(edtFone1.getText());
        cl.setEMP_FONE2(edtFone2.getText());
        cl.setEMP_FAX(edtFax.getText());
        cl.setEMP_EMAIL(edtEmail.getText());
        cl.setEMP_SLOGAN(edtSlogan.getText());
        cl.setEMP_SENHA(edtSenha.getText());
        cl.setEMP_BAIRRO(edtBairro.getText());
        cl.setEMP_SMTP(edtSMTP.getText());
       //cl.setEMP_PORTA(Integer.parseInt(edtPorta.getText()) );
        cl.setEMP_PORTA(0);
        cl.setEMP_INFOADIC(edtInfAdic.getText());
    }
}
